using System;
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using DG.Tweening;
using UnityEngine;

public enum CameraDir
{
    Center = 0,
    Up = 1,
    Down = -1,
    Left = 2,
    Right = -2
}

public class PlayerFocus : MonoBehaviour
{
    public Vector2 Offset;
    public CinemachineVirtualCamera camera;
    public CameraDir flag = CameraDir.Center;

    private CinemachineFramingTransposer body;

    private void Start()
    {
        body = camera.GetCinemachineComponent<CinemachineFramingTransposer>();
    }

    public void Switch()
    {
        var newScreen = Vector2.one * 0.5f;
        switch (flag)
        {
            case CameraDir.Down:
                newScreen.y -= Offset.y;
                break;
            case CameraDir.Up:
                newScreen.y += Offset.y;
                break;
            case CameraDir.Right:
                newScreen.x -= Offset.x;
                break;
            case CameraDir.Left:
                newScreen.y += Offset.x;
                break;
            case CameraDir.Center:
            default:
                break;
        }

        Vector2 screen = Vector2.one * 0.5f;
        DOTween.To(()=> screen, (newParam) =>
        {
            body.m_ScreenX = newParam.x;
            body.m_ScreenY = newParam.y;
        }, newScreen,4f);
    }
}